package learning.objectLock;

public class Syn1 {
	public static void main(String[] args) {
		Bank b = new Bank();
		Thread t1 = new Thread(b, "Tom");
		Thread t2 = new Thread(b, "Jerry");
		t1.start();
		t2.start();
	}

}

class Bank implements Runnable {
	private int money = 20000;
	Object obj = new Object();

	@Override
	public void run() {
		System.out.println(Thread.currentThread().getName()+" is waiting!");
		synchronized (String.class) {
//			System.out.println(String.class);
			System.out.println(Thread.currentThread().getName()+" is banking money from Bank");
			try {
				Thread.sleep(1000);
			} catch (Exception e) {
				e.printStackTrace();
			}
			money -= 2000;
		}
		System.out.println(this.money);
		}

}